<template>
  <div class="singer">
    <div class="title">
      歌手详情
      <div class="fanhui">
        <span class="iconfont icon-fanhui" @click="back()"></span>
      </div>
    </div>

    <div class="information" v-if="singerArtist != null">
      <div class="left">
        <h3>{{ singerArtist.name }}</h3>
        <!-- <span>{{ singerIdentify.imageDesc }}</span> -->
      </div>
      <div class="right">
        <img :src="singerArtist.cover" alt="" />
      </div>
      <div class="text">
        {{ singerArtist.briefDesc }}
      </div>
    </div>
    <load-animate v-else></load-animate>
    <h2 class="hot">热门作品<span @click="playall">播放全部</span></h2>
    <music-list
      v-if="singerMusic.length > 0"
      :musiclist="singerMusic"
      :shownum="true"
      @play="$emit('play', $event)"
      @isfull="isfull = $event"
    ></music-list>
    <load-animate v-else></load-animate>
  </div>
</template>

<script>
import MusicList from "../components/MusicList.vue";
export default {
  components: { MusicList },
  props: {
    singerid: {
      type: String,
      define: "",
    },
  },
  data() {
    return {
      singerArtist: [],
      singerIdentify: [],
      singerMusic: [],
    };
  },
  created() {
    this.getInformation();
    this.getsingerMusic();
  },
  methods: {
    async getInformation() {
      await this.axios.get(`/artist/detail?id=${this.singerid}`).then((res) => {
        this.singerArtist = res.artist;
        this.singerIdentify = res.identify;
      });
    },
    async getsingerMusic() {
      await this.axios
        .get(`/artist/top/song?id=${this.singerid}`)
        .then((res) => {
          this.singerMusic = res.songs.map((item) => {
            item.song = {
              alias: item.alia,
              privilege: item.privilege,
              artists: item.ar,
              album: item.al,
            };
            return item;
          });
        });
    },
    // 全部添加到播放列表
    playall() {
      this.singerMusic.forEach((item) => {
        this.$emit("play", item);
      });
    },
    back() {
      history.back();
    },
  },
};
</script>

<style lang="scss" scoped>
.singer {
  position: relative;
  .fanhui {
    text-align: center;
    position: absolute;
    font-size: 16px;
    line-height: 45px;
    z-index: 101;
    color: #fff;
    span {
      position: absolute;
      left: 10px;
      top: -35px;
    }
  }
  .title {
    font-size: 20px;
    color: #666;
    height: 30px;
    line-height: 23px;
    padding: 0 10px;
    text-align: center;
    background-color: #fff;
    padding: 10px 0;
  }
  .information {
    width: 100%;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 10;
    overflow: hidden;
    font-size: 12px;
    .left {
      h3 {
        font-size: 30px;
        font-weight: bold;
        margin: 5px 0 10px 10px;
      }
      span {
        display: block;
        color: #999;
        margin: 5px 0 15px 10px;
      }
    }
    .right {
      float: right;
      clear: both;
      padding-right: 10px;
      img {
        width: 100px;
        height: 100px;
        border-radius: 50%;
      }
    }
    .text {
      text-indent: 2em;
      padding: 0px 10px;
    }
  }
  .hot {
    font-size: 16px;
    color: #f00;
    font-weight: bold;
    margin-top: 20px;
    position: relative;
    height: 23px;
    line-height: 23px;
    padding: 10px 10px;
    background-color: #eeeff0;
  }
  span {
    position: absolute;
    top: 10px;
    right: 10px;
    color: rgb(58, 174, 174);
  }
}
</style>
